﻿Public Class frmProduct

    Private Sub frmProduct_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
        Dim frm As New frmNewProduct
        frm.ShowDialog()
    End Sub

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()
        UI.FormatDataGrid(dgvlist)
        UI.SetPlaceHolder(txtsearch, "Search")
        dgvlist.DataSource = ClassStock.LoadProduct(txtsearch.Text)
        ' Add any initialization after the InitializeComponent() call.

    End Sub

    Private Sub txtsearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsearch.TextChanged
        ' loaddata()
        dgvlist.DataSource = ClassStock.LoadProduct(txtsearch.Text)
    End Sub
    Public Sub loaddata()
        Cmd.Parameters("@search") = "%" & txtsearch.Text & "%"
        dgvlist.DataSource = Cmd.ExecuteDataTable("select s.makeup_price,s.sell_out_riel,s.new_price,s.old_price,i.item_name,i.item_code,i.alert from tbl_item i left join tbl_stock s on s.item_id=i.item_id where UPPER(i.item_name) like UPPER(@search) ")
    End Sub
End Class